import express from 'express'
const router = express.Router()
import SuccessModel from '../module/SuccessModel.js'
import ErrorModel from '../module/ErrorModel.js'

import knex from '../utils/myKenx.js'

// 新增英雄接口
router.post('/message', (req, response) => {
  const { content, nickName } = req.body
  knex('message')
    .insert({ content, nickName })
    .then(res => {
      response.send(new SuccessModel({ msg: '新增成功' }))
    })
    .catch(err => {
      console.log(err)
      response.send(new ErrorModel({ msg: '新增失败' }))
    })
})

// module.exports = router
export default router
